#ifndef __GSM__VIEW_H__
#define __GSM__VIEW_H__

#include <gtk/gtk.h>
#include "gsm-watcher.h"

G_BEGIN_DECLS

#define GSM_TYPE_VIEW				(gsm_view_get_type ())
#define GSM_VIEW(obj)				(G_TYPE_CHECK_INSTANCE_CAST ((obj), GSM_TYPE_VIEW, GsmView))
#define GSM_VIEW_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST ((klass), GSM_TYPE_VIEW, GsmViewClass))
#define GSM_IS_VIEW(obj)			(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSM_TYPE_VIEW))
#define GSM_IS_VIEW_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), GSM_TYPE_VIEW))
#define GSM_VIEW_GET_CLASS(obj)		(G_TYPE_INSTANCE_GET_CLASS ((obj), GSM_TYPE_VIEW, GsmViewClass))

typedef struct _GsmView GsmView;
typedef struct _GsmViewClass GsmViewClass;

struct _GsmView {
	GtkWindow parent_widget;
	
	GtkBuilder *builder;
	GtkEntry *address;
	GtkButton *remove_server;
	GtkTreeView *players_list;
	GtkTreeView *servers_list;
	GtkEntry *friends_entry;
	GtkButton *remove_friend;
	GtkTreeView *friends_list;
	
	GtkLabel *address_label;
	GtkLabel *name_label;
	GtkLabel *game_label;
	GtkLabel *map_label;
	GtkLabel *players_label;
	GtkLabel *version_label;
	
	GtkToggleAction *pause_action;
	GtkWidget *pause_button;
	GtkSpinButton *prefs_update_rate;
	GtkFileChooserButton *prefs_sound;
	
	GtkStatusIcon *tray_icon;
	GtkMenu *tray_menu;
	GtkMenuItem *tray_menu_show;
	GtkMenuItem *tray_menu_pause;
	
	GsmWatcher *selected;
};

struct _GsmViewClass {
	GtkWindowClass parent_class;
	
	void (*server_add) (GsmView *view, const gchar *address, gpointer user_data);
	void (*server_remove) (GsmView *view, GsmWatcher *watcher, gpointer user_data);
	gboolean (*address_change) (GsmView *view, const gchar *address, gpointer user_data);
	void (*preference_change) (GsmView *view, const gchar *param_name,
			gpointer value, gpointer user_data);
	void (*friend_add) (GsmView *view, const gchar *name, gpointer user_data);
	void (*friend_update) (GsmView *view, const gchar *name, gboolean notify,
			gpointer user_data);
	void (*friend_remove) (GsmView *view, const gchar *name, gpointer user_data);
	gboolean (*friend_name_change) (GsmView *view, const gchar *name, gpointer user_data);
};

GType gsm_view_get_type (void) G_GNUC_CONST;
GtkWidget *gsm_view_new ();

void gsm_view_add_server (GsmView *view, GsmWatcher *watcher);
void gsm_view_update_server (GsmView *view, GsmWatcher *watcher);
void gsm_view_remove_server (GsmView *view, GsmWatcher *watcher);
void gsm_view_error (GsmView *view, GsmWatcher *watcher, GError *error);

void gsm_view_add_friend (GsmView *view, const gchar *name, gboolean notify);
void gsm_view_update_friend (GsmView *view, const gchar *name,
		const gchar *address, gboolean notify);
void gsm_view_remove_friend (GsmView *view, const gchar *name);

void gsm_view_show (GsmView *view);
void gsm_view_hide (GsmView *view);

void gsm_view_set_update_rate (GsmView *view, glong rate);
void gsm_view_set_notification_sound (GsmView *view, gchar *fname);

G_END_DECLS

#endif